package org.geektimes.base.util;

import java.lang.reflect.Field;

/**
*   代理工具类
* @author : KangNing Hu
*/
public class ProxyUtils {

	private final static  String JDK_PROXY_H = "h";

	private final static String JDK_PROXY_TARGET = "target";


	/**
	 * 获取目标类
	 * @param proxy
	 * @return
	 */
	public static Object getTarget(Object proxy){
		Field field = ReflectionUtils.getField(proxy.getClass(), JDK_PROXY_H);
		Object h = ReflectionUtils.get(field, proxy);
		Field personProxyField = ReflectionUtils.getField(h.getClass(), JDK_PROXY_TARGET);
		return ReflectionUtils.get(personProxyField , h);
	}

}




